package 多线程.Lambda推导在Thread的应用;

/**
 * lambda推导 + 参数
 * （lambda是为了避免内部类定义过多）
 */
public class LambdaTest02 {
    //2.静态内部类
    static class love2 implements ILove {
        @Override
        public void lambda(int a) {
            System.out.println("i like lambda2" + a);
        }


    }

    public static void main(String[] args) {
        ILove love = new love();
        love.lambda(1);

        love = new love2();
        love.lambda(2);

        //3.匿名内部类
        love = new ILove() {
            @Override
            public void lambda(int a) {
                System.out.println("lambda3" + a);
            }
        };
        love.lambda(3);

        //4.lambda
        love = (int a) -> {
            System.out.println("lambda3"+ a);
        };
        love.lambda(4);


        //5.简化
        love = a -> {
            System.out.println("lambda5"+ a);
        };
        love.lambda(5);

        //6.当代码只有一行时
        love = a ->
            System.out.println("lambda5"+ 6);

        love.lambda(6);

    }
}

interface ILove {
    void lambda(int a);
}

//1.外部类
class love implements ILove {
    @Override
    public void lambda( int a) {
        System.out.println("i like lambda"  + a +"千遍");
    }
}
